﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Text.RegularExpressions;
using System.Globalization;
using CRMFramework;

namespace CRMEntity
{
    public class ClientInfo
    {
        public Int32 ContactID { set; get; }
        public string FirstName { set; get; }
        public string MiddleName { set; get; }
        public string SurName { set; get; }
        public string Title { set; get; }
        public string Gender { set; get; }
        public string Mobile { set; get; }
        public string HomePhone { set; get; }
        public string Email { set; get; }
        public string DriverLicense { set; get; }
        public string Citizenship { set; get; }
        public string DateBirth { set; get; }
        public string StreetNo { set; get; }
        public string Street { set; get; }
        public string Suburb { set; get; }
        public string State { set; get; }
        public string PostCode { set; get; }
        public string ResidencePeriod { set; get; }
        public string ResidenceLength { set; get; }
        public string Dependant { set; get; }
        public string app_ResidentialStatus { set; get; }
        public string app_number { set; get; }
        public string app_id { set; get; }
        public string NumberFromAppinfo { set; get; }
        public string Memo { set; get; }
        public string EditDate { set; get; }
        public int DupwithContact { set; get; }
        public int deletedFlag { set; get; }
        public string Role { set; get; }
        public string Relationship { set; get; }
        public string WorkPhone { set; get; }
        public string FaxNumber { set; get; }
        public string secondEmailAddress { set; get; }
        public string PostalAddress { set; get; }
        public string IncomeType { set; get; }
        public string SelfEmpTypeofEntity { set; get; }
        public string SelfEmpBusinessName { set; get; }
        public string SelfEmpABN { set; get; }
        public string SelfEmpNatureofBusiness { set; get; }
        public string SelfEmpPhone { set; get; }
        public string SelfEmpAddress { set; get; }
        public string KinsName { set; get; }
        public string KinsRelationship { set; get; }
        public string KinsContactNumber { set; get; }
        public string Notes { set; get; }
        public string EmpEmployer { set; get; }
        public string EmpOccupation { set; get; }
        public string EmpJobPosition { set; get; }
        public string EmpEmployerPhone { set; get; }
        public string EmpContactPerson { set; get; }
        public string EmpWorkAddress { set; get; }
        public string comesfrom { set; get; }
        public string Unsubscribe_Ad { set; get; }
        public string Sacc_accountlock { set; get; }
        public string CreateDate { set; get; }
        public string Operator { set; get; }

        public ClientInfo() { }

        public DataSet AddClientDetail()
        {
            DataSet ds;
            try
            {
                DateTime dtDateBirth = new DateTime();
                DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
                dtfi.ShortDatePattern = "yyyy-MM-dd";
                dtfi.DateSeparator = "-";
                if (!string.IsNullOrEmpty(DateBirth))
                    dtDateBirth = Convert.ToDateTime(DateBirth, dtfi);

                var para = new[] {
                    DBhelper.SetParameter("p_Title",Title),
                    DBhelper.SetParameter("p_FirstName",FirstName),
                    DBhelper.SetParameter("p_MiddleName",MiddleName),
                    DBhelper.SetParameter("p_SurName",SurName),
                    DBhelper.SetParameter("p_Citizenship",Citizenship),
                    DBhelper.SetParameter("p_DateBirth",dtDateBirth),
                    DBhelper.SetParameter("p_DriverLicense",DriverLicense),
                    DBhelper.SetParameter("p_Mobile",Mobile),
                    DBhelper.SetParameter("p_HomePhone",HomePhone),
                    DBhelper.SetParameter("p_Email", Email),
                    DBhelper.SetParameter("p_secondEmailAddress",secondEmailAddress),
                    DBhelper.SetParameter("p_Street",Street),
                    DBhelper.SetParameter("p_StreetNo",StreetNo),
                    DBhelper.SetParameter("p_Suburb",Suburb),
                    DBhelper.SetParameter("p_State",State),
                    DBhelper.SetParameter("p_PostCode",PostCode),
                    DBhelper.SetParameter("p_app_ResidentialStatus", app_ResidentialStatus),
                    DBhelper.SetParameter("p_ResidencePeriod", ResidencePeriod),
                    DBhelper.SetParameter("p_unsubscribe_Ad",  Unsubscribe_Ad),
                    DBhelper.SetParameter("p_Sacc_accountlock", Sacc_accountlock),
                    DBhelper.SetParameter("p_ResidenceLength",  ResidenceLength),
                    DBhelper.SetParameter("p_Dependant", Dependant),
                    DBhelper.SetParameter("p_Memo", Memo),
                    DBhelper.SetParameter("p_historyOperator",Operator)
                };

                ds = DBhelper.ExecuteDatasetSP("sp_addContactHistory", para);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ds;
        }
        public int UpdateClientDetail()
        {
            int intReturnValue = 0;
            try
            {
                DateTime dtDateBirth = new DateTime();
                DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
                dtfi.ShortDatePattern = "yyyy-MM-dd";
                dtfi.DateSeparator = "-";
                if (DateBirth != "")
                    dtDateBirth = Convert.ToDateTime(DateBirth, dtfi);
                var para = new[] {
                    DBhelper.SetParameter("p_ContactID",ContactID),
                    DBhelper.SetParameter("p_Title",Title),
                    DBhelper.SetParameter("p_FirstName",FirstName),
                    DBhelper.SetParameter("p_MiddleName",MiddleName),
                    DBhelper.SetParameter("p_SurName",SurName),
                    DBhelper.SetParameter("p_Citizenship",Citizenship),
                    DBhelper.SetParameter("p_DateBirth",dtDateBirth),
                    DBhelper.SetParameter("p_DriverLicense",DriverLicense),
                    DBhelper.SetParameter("p_Mobile",Mobile),
                    DBhelper.SetParameter("p_HomePhone",HomePhone),
                    DBhelper.SetParameter("p_Email", Email),
                    DBhelper.SetParameter("p_secondEmailAddress", secondEmailAddress),
                    DBhelper.SetParameter("p_Street",Street),
                    DBhelper.SetParameter("p_StreetNo",StreetNo),
                    DBhelper.SetParameter("p_Suburb",Suburb),
                    DBhelper.SetParameter("p_State",State),
                    DBhelper.SetParameter("p_PostCode",PostCode),
                    DBhelper.SetParameter("p_app_ResidentialStatus", app_ResidentialStatus),
                    DBhelper.SetParameter("p_ResidencePeriod", ResidencePeriod),
                    DBhelper.SetParameter("p_unsubscribe_Ad",  Unsubscribe_Ad),
                    DBhelper.SetParameter("p_Sacc_accountlock",  Sacc_accountlock),
                    DBhelper.SetParameter("p_ResidenceLength",  ResidenceLength),
                    DBhelper.SetParameter("p_Dependant", Dependant),
                    DBhelper.SetParameter("p_Memo", Memo),
                    DBhelper.SetParameter("p_historyOperator",Operator)
                };

                DBhelper.ExecuteNonQuerySP("sp_updateContactHistory", para);
                intReturnValue = 1;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return intReturnValue;
        }


    }
}
